package cn.tedu.submarine;

import javax.swing.ImageIcon;

/**
 * 深水炸弹类
 */
public class Bomb extends SeaObject{
    public static final int LEFT = 0;//左侧炸弹状态
    public static final int MIDDLE = 1;//下方炸弹状态
    public static final int Right = 2;//右侧炸弹状态
    private int bombMarker = MIDDLE;//炸弹编号默认下方
    private int marker;//战舰编号


    public Bomb(int x,int y,int bombMarker,int marker){
        super(20,20,x,y,3);
        this.bombMarker = bombMarker;//炸弹编号
        this.marker = marker;
    }

    public int getMarker(){//获取战舰编号
        return marker;
    }

    public void move(){//炸弹运动方法
        if (bombMarker==LEFT){//左侧
            setX(getX() - getSpeed()/2);
            setY(getY() + getSpeed());
        }else if (bombMarker==Right){//右侧
            setX(getX() + getSpeed()/2);
            setY(getY() + getSpeed());
        }else {//下方
            setY(getY() + getSpeed());
        }

    }

    public ImageIcon getImage(){//画炸弹
        return Images.bomb;
    }
    public boolean isOutBounds(){//炸弹越界判定
        return getY() >= World.HEIGHT || getX() <= 0-getWidth() ||getX()>= World.WIDTH;
    }
}
